package com.yby6.web.controller.system;

import com.yby6.common.core.controller.BaseController;
import com.yby6.system.domain.SysLog;
import com.yby6.system.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yby6.common.core.AjaxResult;
import com.yby6.common.core.page.TableDataInfo;

/**
 * @program: yangbuyi-rbac
 * @ClassName: SysLogController
 * @create: 2021-05-31 10:44
 * @author: Yang Shuai
 * @since： JDK1.8
 * @SysLogController: 系统日志$
 **/
@RestController
@RequestMapping("sysLog")
public class SysLogController extends BaseController {

    @Autowired
    private SysLogService sysLogService;

    /**
     * 分页查询
     *
     * @param sysLogDto
     * @return
     */
    @PostMapping
    public TableDataInfo getLogByPage (@RequestBody SysLog sysLog) {
        startPage(sysLog.getPageNum(), sysLog.getPageSize());
        return getDataTable(sysLogService.getLogByPage(sysLog));
    }


    /**
     * 根据ID查询
     *
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public AjaxResult getLogById (@PathVariable Long id) {
        return AjaxResult.success(sysLogService.getLogById(id));
    }

    /**
     * 根据id删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("/{ids}")
    public AjaxResult deleteById (@PathVariable Long[] ids) {
        return toAjax(sysLogService.deleteById(ids));
    }


    /**
     * 清空日志信息
     * @return
     */
    @DeleteMapping("/all")
    public AjaxResult deleteAll () {
        return toAjax(sysLogService.deleteAll());
    }

}
